// 场景：接口回显字段，循环匹配。
data = {
    id: '',
    name: '',
    weapon: ''
}

resp = {
    body: {
        id: '123',
        name: 'kaka',
        date: '2019-5-23'
    }
}

for (let name of Object.getOwnPropertyNames(data)) {
    if (resp.body[name]) {
        data[name] = resp.body[name]
    }
}

console.log(data);
